#include "MsgSizeCond.h"

using namespace kc_sf;

// -------------------------------------------------------- //

MsgSizeCond::MsgSizeCond( unsigned long size, Operator op )
: c_size_operator( op ),
  c_size( size )
{
}

// -------------------------------------------------------- //

Logic::Symbol *MsgSizeCond::clone() const
{
	return new MsgSizeCond( *this );
}

// -------------------------------------------------------- //

bool MsgSizeCond::eval( const Message &msg )
{
	return
		c_size_operator == Eq ? msg.mSize == c_size
		: c_size_operator == Ge ? msg.mSize >= c_size
		: c_size_operator == Gt ? msg.mSize > c_size
		: c_size_operator == Le ? msg.mSize <= c_size
		: c_size_operator == Lt ? msg.mSize < c_size
		: c_size_operator == Ne ? msg.mSize != c_size
		: msg.mSize >= c_size;
}
